home *** CD-ROM | disk | FTP | other *** search
/ Delphi Developer's Kit 1996 / Delphi Developer's Kit 1996.iso / power / enterctl / entgrid.pas < prev    next >
Pascal/Delphi Source File  |  1995-12-22  |  966b  |  54 lines

  1. unit Entgrid;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, Grids;
  8.  
  9. type
  10.   TEnterGrid = class(TStringGrid)
  11.   private
  12.     { Private declarations }
  13.   protected
  14.     { Protected declarations }
  15.     procedure KeyPress(var Key: Char); override;
  16.   public
  17.     { Public declarations }
  18.   published
  19.     { Published declarations }
  20.   end;
  21.  
  22. procedure Register;
  23.  
  24. implementation
  25.  
  26. procedure Register;
  27. begin
  28.   RegisterComponents('Samples', [TEnterGrid]);
  29. end;
  30.  
  31. procedure TEnterGrid.KeyPress(var Key: Char);
  32. begin
  33.  
  34.    if Key = #13 then
  35.    begin
  36.        if Col < (ColCount - FixedCols) then
  37.        begin
  38.            Col := Col + 1;
  39.            Key := #0;
  40.        end
  41.        else if Row < (RowCount - FixedRows) then
  42.        begin
  43.            Col := 1;
  44.            Row := Row + 1;
  45.            Key := #0;
  46.        end;
  47.    end;
  48.  
  49.    if Key <> #0 then inherited KeyPress(Key);
  50.  
  51. end;
  52.  
  53. end.
  54.